#pragma once 
#ifndef __OPERATE_UI_H__
#define __OPERATE_UI_H__


#include "IOptionUi.h"
#include "sqlite3\sqlite3.h"


typedef enum _en_sql_type
{
  GRID_VIEW_SQL0 = 0,
  GRID_VIEW_SQL1 = 1,
  GRID_VIEW_SQL2 = 2,
}EN_SQL_TYPE;

class COperateUi: public virtual IOperateUi
{
INIT_CLASS_SINGLETON(COperateUi)
public:
  const bool Init(const void * pvdPara, char * pszMsgTxt, int iMsgTxtSize);
  string GetKey(string & strKey);
  bool SetKey(const string & strKey);
  ITable & TableNorm();
  ITable & TableConfig();
  int GetConfigInfo(const char * pszAreaId, const char * pszOutFieldName);
  const bool InitGridCol(::HWND hXtpReport, const char * pszAreaId, const bool bColTitleHide);
  const bool InitInfoGrid(::HWND hXtpReport, const char * pszAreaId);
  const bool LoadInfoGrid(::HWND hXtpReport, IValueSet * ptrValueSet, const char * pszAreaId);
  const bool LoadInfoGrid(::HWND hXtpReport, ITable * ptrTable, const char * pszAreaId, const char * pszTableName);
  const bool UpdGridVal(::HWND hXtpReport, IValueSet * ptrValueSet, const char * pszAredId, const char * pszName, const COLORREF dwBackgroundColor = -1, const COLORREF dwFontColor = -1);
  const bool UpdGridVal(::HWND hXtpReport, IValueSet * ptrValueSet, const char * pszAredId, const char * pszName, int iRow, const COLORREF dwBackgroundColor = -1, const COLORREF dwFontColor = -1);
  const bool UpdGridVal(::HWND hXtpReport, const char * ptrValue, int iRow, int iCol, const COLORREF dwBackgroundColor = -1, const COLORREF dwFontColor = -1);
  const bool ClearGrid(::HWND hXtpReport);
  const bool DelGridRow(::HWND hXtpReport, int iRow);
  const bool InitGridRow(::HWND hXtpReport, const char * pszAredId, int iSumRow);
  const bool UpdGridSelect(::HWND hXtpReport, const char * pszAredId, int iColId, int iState = 1);
  const bool GetGridSelect(::HWND hXtpReport, const char * pszAredId, int iColId, vector<int> & vtSelectNo);
  const void BgnUpdate(::HWND hXtpReport);
  const void EndUpdate(::HWND hXtpReport);
  const int GridSumRow(::HWND hXtpReport);
  const int GridSumCol(::HWND hXtpReport);
  const int GridSelectRowNo(::HWND hXtpReport);
  const string GetGridCellVal(::HWND hXtpReport, int iRow, int iCol, string & strVal);
  const string GetGridCellVal(::HWND hXtpReport, const char * pszAredId, const char * pszName, int iRow, string & strVal);
  const COLORREF GetCellBackgroundColor(::HWND hXtpReport, int iRow, int iCol);
  const COLORREF GetCellFontColor(::HWND hXtpReport, int iRow, int iCol);
  void ProcessMessage();
private:
    bool LoadNorm();
	bool LoadSqlLiteData(ITable * ptrTable, const char * pszDbName, const char * pszSqlTxt);
	bool SetConfigInfo(const string & strAreaId, const string & strOutFieldName, const int iRecNo = -1);

private:
  sqlite3 * m_ptrdb;
  ITable * m_ptrQryNorm, * m_ptrQryConfig;
  IValueSet * m_ptrArea;

};



#endif // !__OPERATE_UI_H__

